<template>
  <div>
    <div class="navbar-wrapper">
      <div class="container">
        <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
          <div class="container">
            <div class="navbar-header">
              <a class="navbar-brand" href="#" style="font-size:32px;">尚筹网-创意产品众筹平台</a>
            </div>
            <div id="navbar" class="navbar-collapse collapse" style="float:right;">
              <ul class="nav navbar-nav navbar-right">
                <template v-if="!user.isLogin">
                  <li>
                    <router-link to="/login">登录</router-link>
                  </li>
                  <li>
                    <router-link to="/register">注册</router-link>
                  </li>
                </template>
                <template v-else>
                  <li>
                    <h4>{{ user.userName }}</h4>
                  </li>
                  <li>
                    <h4 class="logout" @click="logoutBtn">退出</h4>
                  </li>
                  <li>
                    <router-link class="logout" :to="{name:'Member',params:{user:user.userName}
                  }">个人中心
                    </router-link>
                  </li>
                </template>
                <li><a>|</a></li>
                <li>
                  <router-link to="/admin/login">管理员入口</router-link>
                </li>
              </ul>
            </div>
          </div>
        </nav>
      </div>
    </div>
    <!-- Carousel
    ================================================== -->
    <div id="myCarousel" class="carousel slide" data-ride="carousel">
      <!-- Indicators -->
      <ol class="carousel-indicators">
        <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
        <li data-target="#myCarousel" data-slide-to="1"></li>
        <li data-target="#myCarousel" data-slide-to="2"></li>
      </ol>
      <div class="carousel-inner" role="listbox">
        <div class="item active" onclick="window.location.href='project.html'" style="cursor:pointer;">
          <img src="~@/assets/img/carousel-1.jpg" alt="First slide">
        </div>
        <div class="item" onclick="window.location.href='project.html'" style="cursor:pointer;">
          <img src="~@/assets/img/carousel-2.jpg" alt="Second slide">
        </div>
        <div class="item" onclick="window.location.href='project.html'" style="cursor:pointer;">
          <img src="~@/assets/img/carousel-3.jpg" alt="Third slide">
        </div>
      </div>
      <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
        <span class="glyphicon glyphicon-chevron-left"></span>
        <span class="sr-only">Previous</span>
      </a>
      <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
        <span class="glyphicon glyphicon-chevron-right"></span>
        <span class="sr-only">Next</span>
      </a>
    </div><!-- /.carousel -->
    <!-- Marketing messaging and featurettes
    ================================================== -->
    <!-- Wrap the rest of the page in another container to center all the content. -->
    <div class="container marketing">

      <!-- Three columns of text below the carousel -->
      <div class="row">
        <div class="col-lg-4">
          <img class="img-circle" src="~@/assets/img/p1.jpg" alt="Generic placeholder image"
               style="width: 140px; height: 140px;">
          <h2>智能高清监控机器人</h2>
          <p>可爱的造型，摄像安防远程互联的全能设计，让你随时随地守护您的家人，陪伴你的生活。</p>
          <p><a class="btn btn-default" href="project.html" role="button">项目详情 &raquo;</a></p>
        </div><!-- /.col-lg-4 -->
        <div class="col-lg-4">
          <img class="img-circle" src="~@/assets/img/p2.jpg" alt="Generic placeholder image"
               style="width: 140px; height: 140px;">
          <h2>NEOKA智能手环</h2>
          <p>要运动更要安全，这款、名为“蝶舞”的NEOKA-V9100智能运动手环为“安全运动而生”。</p>
          <p><a class="btn btn-default" href="project.html" role="button">项目详情 &raquo;</a></p>
        </div><!-- /.col-lg-4 -->
        <div class="col-lg-4">
          <img class="img-circle" src="~@/assets/img/p3.png" alt="Generic placeholder image"
               style="width: 140px; height: 140px;">
          <h2>驱蚊扣</h2>
          <p>随处使用的驱蚊纽扣，<br>解决夏季蚊虫问题。</p>
          <p><a class="btn btn-default" href="project.html" role="button">项目详情 &raquo;</a></p>
        </div><!-- /.col-lg-4 -->
      </div><!-- /.row -->

      <TypeProject></TypeProject>

      <!-- FOOTER -->
      <div class="container">
        <div class="row clearfix">
          <div class="col-md-12 column">
            <div id="footer">
              <div class="footerNav">
                <a rel="nofollow" href="http://www.atguigu.com">关于我们</a> | <a rel="nofollow"
                                                                              href="http://www.atguigu.com">服务条款</a>
                | <a rel="nofollow" href="http://www.atguigu.com">免责声明</a> | <a rel="nofollow"
                                                                                href="http://www.atguigu.com">网站地图</a>
                | <a rel="nofollow" href="http://www.atguigu.com">联系我们</a>
              </div>
              <div class="copyRight">
                Copyright ?2017-2017atguigu.com 版权所有
              </div>
            </div>

          </div>
        </div>
      </div>

    </div>
  </div>
</template>
<script setup>

import {onMounted, reactive} from "vue";
import {memberLogout} from "@/api/member/user";
import {errorsMsg, getSession, removeAllSession, successMsg} from "@/utils/web-utils";
import {useRouter} from "vue-router";
import {userStore} from "@/store/userstore";
import TypeProject from "@/views/home/component/TypeProject.vue";


const router = useRouter()

const user = reactive({
  userName: '',
  isLogin: false
});


const userStores = userStore();

const logoutBtn = () => {
  ElMessageBox.confirm(
      '是否要退出登录?',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }
  )
      .then(() => {
        memberLogout().then(res => {
          if (res.code !== 200) {
            return errorsMsg(res.message)
          }
          removeAllSession();
          user.isLogin = false;
          successMsg(res.message)
        })
      })
}

onMounted(() => {
  if (getSession("userName")) {
    user.userName = getSession("userName");
    user.isLogin = true;
  }

})

</script>

<style lang="scss" scoped>

h3 {
  font-weight: bold;
}

.navbar-right {
  h4 {
    color: #9acfea;
    margin-top: 15px;
    padding-left: 10px;
  }

  .logout {
    cursor: pointer;
  }

  .logout:hover {
    color: #00CCFF;
  }
}

#footer {
  padding: 15px 0;
  background: #fff;
  border-top: 1px solid #ddd;
  text-align: center;
}

#topcontrol {
  color: #fff;
  z-index: 99;
  width: 30px;
  height: 30px;
  font-size: 20px;
  background: #222;
  position: relative;
  right: 14px !important;
  bottom: 11px !important;
  border-radius: 3px !important;
}

#topcontrol:after {
  /*top: -2px;*/
  left: 8.5px;
  content: "\f106";
  position: absolute;
  text-align: center;
  font-family: FontAwesome;
}

#topcontrol:hover {
  color: #fff;
  background: #18ba9b;
  -webkit-transition: all 0.3s ease-in-out;
  -moz-transition: all 0.3s ease-in-out;
  -o-transition: all 0.3s ease-in-out;
  transition: all 0.3s ease-in-out;
}

/* 侧栏导航 */
.sideBox {
  padding: 10px;
  height: 220px;
  background: #fff;
  margin-bottom: 10px;
  overflow: hidden;
}

.sideBox .hd {
  height: 30px;
  line-height: 30px;
  background: #f60;
  padding: 0 10px;
  text-align: center;
  overflow: hidden;
}

.sideBox .hd .more {
  color: #fff;
}

.sideBox .hd h3 span {
  font-weight: bold;
  font-size: 14px;
  color: #fff;
}

.sideBox .bd {
  padding: 5px 0 0;
}

#sideMenu .bd li {
  margin-bottom: 2px;
  height: 30px;
  line-height: 30px;
  text-align: center;
  overflow: hidden;
}

#sideMenu .bd li a {
  display: block;
  background: #EAE6DD;
}

#sideMenu .bd li span {
  display: block;
  background: #EAE6DD;
}


#sideMenu .bd li a:hover {
  background: #D5CFBF;
}


/* 列表页 */
#mainBox {
  margin-bottom: 10px;
  padding: 10px;
  background: #fff;
  overflow: hidden;
}

#mainBox .mHd {
  border-bottom: 2px solid #09c;
  height: 30px;
  line-height: 30px;
}

#mainBox .mHd h3 {
  display: initial;
  *display: inline;
  zoom: 1;
  padding: 0 15px;
  background: #09c;
  color: #fff;
}

#mainBox .mHd h3 span {
  color: #fff;
  font-size: 14px;
  font-weight: bold;
}

#mainBox .path {
  float: right;
}

/* 位置导航 */
.path {
  height: 30px;
  line-height: 30px;
  padding-left: 10px;
}

.path a, .path span {
  margin: 0 5px;
}

/* 文章列表 */
.newsList {
  padding: 10px;
  text-align: left;
}

.newsList li {
  padding-left: 10px;
  height: 30px;
  line-height: 30px;
}

.newsList li a {
  display: inline-block;
  *display: inline;
  zoom: 1;
  font-size: 14px;
}

.newsList li .date {
  float: right;
  color: #999;
}

.newsList li.split {
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px dotted #ddd;
  height: 0px;
  line-height: 0px;
  overflow: hidden;
}

/* 通用带图片的信息列表_普通式 */
.picList {
  padding: 10px;
  text-align: left;
}

.picList li {
  margin: 0 5px;
  height: 190px;
}

h3.break {
  font-size: 16px;
  display: block;
  white-space: nowrap;
  word-wrap: normal;
  overflow: hidden;
  text-overflow: ellipsis;
}

h3.break > a {
  text-decoration: none;
}
</style>